package com.wutuo.tag.provider.dao;

import cn.apestar.core.base.GenericMapper;
import cn.apestar.core.base.MapperAnnotation;
import com.wutuo.tag.provider.domain.Tag;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * 服务关系表 Dao 层
 *
 * @author lvh
 * @version 1.0
 */
@MapperAnnotation public interface BaseTagMapper extends GenericMapper<Tag, Long> {

    @Override @Delete({"delete from tag", "where id = #{id,jdbcType=BIGINT}"})
    int deleteByPrimaryKey(Long id);

    @Override
    @Insert({"insert into tag (", "tag_name,", "tag_type,", "cm_institution_id,", "tag_describe,",
        "create_by,", "create_date,", "update_by,", "update_date,", "remarks,", "del_flag",
        " )values(", "#{tagName,jdbcType=VARCHAR},", "#{tagType,jdbcType=BIGINT},",
        "#{cmInstitutionId,jdbcType=BIGINT},", "#{tagDescribe,jdbcType=VARCHAR},",
        "#{createBy,jdbcType=BIGINT},", "#{createDate,jdbcType=DATE},",
        "#{updateBy,jdbcType=BIGINT},", "#{updateDate,jdbcType=DATE},",
        "#{remarks,jdbcType=VARCHAR},", "#{delFlag,jdbcType=VARCHAR})"}) int insert(Tag record);

    @InsertProvider(type = BaseTagSqlProvider.class, method = "insertSelective")
    int insertSelective(Tag record);

    @Override @Select({"select", "tag_name,", "tag_type,", "cm_institution_id,", "tag_describe,",
        "create_by,", "create_date,", "update_by,", "update_date,", "remarks,", "del_flag",
        "from tag", "where id = #{id,jdbcType=BIGINT}"})
    @Results({@Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
        @Result(column = "tag_name", property = "tagName", jdbcType = JdbcType.VARCHAR),
        @Result(column = "tag_type", property = "tagType", jdbcType = JdbcType.BIGINT),
        @Result(column = "cm_institution_id", property = "cmInstitutionId", jdbcType = JdbcType.BIGINT),
        @Result(column = "tag_describe", property = "tagDescribe", jdbcType = JdbcType.VARCHAR),
        @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.DATE),
        @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.DATE),
        @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
        @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.VARCHAR)})
    Tag selectByPrimaryKey(Long id);

    @Override
    @UpdateProvider(type = BaseTagSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Tag record);

    @Override @Update({"update tag", "set ", "tag_name = #{tagName,jdbcType=VARCHAR},",
        "tag_type = #{tagType,jdbcType=BIGINT},",
        "cm_institution_id = #{cmInstitutionId,jdbcType=BIGINT},",
        "tag_describe = #{tagDescribe,jdbcType=VARCHAR},",
        "create_by = #{createBy,jdbcType=BIGINT},", "create_date = #{createDate,jdbcType=DATE},",
        "update_by = #{updateBy,jdbcType=BIGINT},", "update_date = #{updateDate,jdbcType=DATE},",
        "remarks = #{remarks,jdbcType=VARCHAR},", "del_flag = #{delFlag,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"}) int updateByPrimaryKey(Tag record);
}